package org.lqq.serverRegisterAndFinder.etcd;

import mousio.etcd4j.EtcdClient;
import mousio.etcd4j.promises.EtcdResponsePromise;
import mousio.etcd4j.responses.EtcdKeysResponse;

import java.io.IOException;

/**
 * Created by 李清泉 on 2017/11/2.
 *
 * @remark
 */
public class EtcGuideThread implements Runnable {

    private EtcdClient etcdClient;

    private String address;

    private String serverName;



    public EtcGuideThread(EtcdClient etcdClient,String serverName,String address) {
        this.etcdClient = etcdClient;
        this.address=address;
        this.serverName=serverName;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(40 * 1000);
              etcdClient.refresh(EtcdConst.etcdKey+"/"+EtcdConst.sysKey+"/"+serverName+"-"+address,60).send();
               // p.get();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
